package cn.lili.modules.urbansubstation.entity.dos;

import cn.hutool.core.text.CharSequenceUtil;
import cn.lili.common.utils.BeanUtil;
import cn.lili.common.utils.SnowFlake;
import cn.lili.modules.urbansubstation.entity.dto.UrbanSubstationDTO;
import cn.lili.modules.urbansubstation.entity.enums.UrbanSubstationStatusEnum;
import cn.lili.mybatis.model.BaseSceneEntity;
import cn.lili.mybatis.model.BaseStandardEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serial;
import java.math.BigDecimal;
import java.util.Date;

@Data
@TableName("li_urban_substation")
@ApiModel(value = "城市分站")
@NoArgsConstructor
public class UrbanSubstation extends BaseStandardEntity {

    @Serial
    private static final long serialVersionUID = 1L;

    @NotBlank(message = "分站名称不能为空")
    @ApiModelProperty(value = "城市分站名称")
    private String urbanName;

    @ApiModelProperty(value = "城市分站图标")
    private String urbanIcon;

    @ApiModelProperty(value = "城市分站关键字")
    private String keywords;

    @ApiModelProperty(value = "城市分站描述")
    private String urbanDesc;

    @NotBlank(message = "分站联系方式不能为空")
    @ApiModelProperty(value = "城市分站联系方式")
    private String urbanPhone;

    @ApiModelProperty(value = "城市分站邮箱")
    private String urbanEmail;

    @ApiModelProperty(value = "城市分站QQ")
    private String urbanQq;

    @ApiModelProperty(value = "城市分站微信")
    private String urbanWechat;

    @NotBlank(message = "分站地址不能为空")
    @ApiModelProperty(value = "城市分站城市ID")
    private String areaId;

    @NotBlank(message = "分站地址不能为空")
    @ApiModelProperty(value = "城市分站城市名称")
    private String areaName;

    @ApiModelProperty(value = "城市分站省份ID")
    private String provinceId;

    @ApiModelProperty(value = "城市分站省份名称")
    private String provinceName;

    @ApiModelProperty(value = "城市分站关联用户表ID")
    private String userId;

    /*@NotNull(message = "分站供应商分佣比例不能为空")
    @ApiModelProperty(value = "供应商分佣比例")
    private Double shopRate;

    @NotNull(message = "分站订单分佣比例不能为空")
    @ApiModelProperty(value = "订单分佣比例")
    private Double orderRate;*/

    @ApiModelProperty(value = "结算银行开户名")
    private String settlementBankAccountName;

    @ApiModelProperty(value = "结算公司银行账号")
    private String settlementBankAccountNumber;

    @ApiModelProperty(value = "结算开户银行支行名称")
    private String settlementBankName;

    @ApiModelProperty(value = "结算开户银行所在地")
    private String settlementBankAddress;

    @ApiModelProperty(value = "域名")
    private String urbanDomain;

    @ApiModelProperty(value = "状态")
    private String status;

    @ApiModelProperty(value = "城市分站下供货商数量")
    @TableField(exist = false)
    private Integer supplierCount;

    @ApiModelProperty(value = "城市分站下供货商商品数量")
    @TableField(exist = false)
    private Long supplierGoodsCount;

    @ApiModelProperty(value = "本月新增供货商数量")
    @TableField(exist = false)
    private Long supplierCountByMonth;

    @ApiModelProperty(value = "本月新增商品数量")
    @TableField(exist = false)
    private Long addGoodsCount;

    @ApiModelProperty(value = "上架商品数量")
    @TableField(exist = false)
    private Long upperGoodsCount;

    @ApiModelProperty(value = "违规下架商品数量")
    @TableField(exist = false)
    private Long downGoodsCount;

    @ApiModelProperty(value = "条件获取供应商数量")
    @TableField(exist = false)
    private Long supplierCountByParams;

    @ApiModelProperty(value = "条件获取商品数量")
    @TableField(exist = false)
    private Long goodsCountByParams;

    public UrbanSubstation(UrbanSubstationDTO urbanSubstationDTO) {
        BeanUtil.copyProperties(urbanSubstationDTO, this);

        status = UrbanSubstationStatusEnum.APPLYING.value();
        if (urbanName == null) {
            urbanName = "分站" + SnowFlake.getIdStr();
        }

        if (CharSequenceUtil.isEmpty(getId())) {
            this.setId(SnowFlake.getIdStr());
        }
    }
}
